<template>
  <el-form-item label="UUID" prop="uuid" v-if="enumType === 'FILE'">
    <el-input :value="value" @input="inputChange" placeholder="唯一的id">
      <el-button slot="append" icon="el-icon-refresh" @click="refreshBtnClick"></el-button>
    </el-input>
  </el-form-item>
</template>

<script lang="ts">
  import {Vue, Component, Model, Prop} from 'vue-property-decorator'
  import { get } from '@/api/ajax'
  import { GlobalApi } from '@/api/apis'

  @Component({
    name: 'ComUUIDInput',
  })
  export default class CodeInput extends Vue {

    @Model('change', { type: String }) value!: string
    @Prop({ type: String, default: '' }) enumType!: string

    inputChange(text: string) {
      this.$emit('change', text)
    }

    refreshBtnClick() {
      get<string>(GlobalApi.uuid).then((data) => {
        this.inputChange(data)
      })
    }
  }
</script>

<style scoped>

</style>
